﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>TestMvcRouting - http://www.cnblogs.com/fish-li</title>
    <script type="text/javascript" src="/static/js/jquery/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="/static/js/jquery/jquery.form.js"></script>
    
    <style type="text/css">
    span{ 
    	display: block;
    	float: left;
        width: 70px
     }
    </style>
    
</head>
<body>

<form id="form1" action="xxxxxx" method="post">
	<p><span>Input:</span>
		<input type="text" id="txtInput" style="width: 300px" value="Fish" /></p>
	<p><span>Output:</span>
		<input type="text" id="txtOutput" style="width: 300px" readonly="readonly" /></p>
	<input type="submit" name="Base64" value="转换成Base64编码" />&nbsp;&nbsp;
	<input type="submit" name="Md5" value="计算md5" />&nbsp;&nbsp;
	<input type="submit" name="Sha1" value="计算sha1" />
</form>

<p><br />
<hr />
</p>

<p>
<button id="btnTestAll" >测试所有支持的URL格式</button>
</p>

<div id="autoTestResult">
</div>

<!--说明：路由配置请参考 AppInit.InitRouting 方法（搜索即可找到）。-->

<script type="text/javascript">
	$("input:submit").click(function(){
		var $this = $(this);
		$.ajax({
			url: "/mvc-routing/ns/TestAutoAction/" + $this.attr("name"),
			data: {input: $("#txtInput").val()},
			success: function(responseText){
				$("#txtOutput").val(responseText);
			}
		});
		return false;
	});
	
	function callService(url){
		var result = "";
		$.ajax({
			async: false,
			url: url,
			data: {input: "Fish Li"},
			success: function(responseText){
				result = responseText;
			}
		});
		return result === "44D2D9635ED5CDEA2A858CD7A1CC2B0C";		
	}
	
	$("#btnTestAll").click(function() {
		var links = [
			"/mvc-routing/DEMO.Controllers.Services/TestAutoAction/Md5",
			"/mvc-routing/ns/TestAutoAction/Md5",
			"/mvc-routing-2/with-datataken-full-namespace/TestAutoAction/Md5",
			"/mvc-routing-3/with-datataken-short-namespace/TestAutoAction/Md5"
		];
		
		var html = "";
		$.each(links, function(i, n){
			if( callService(n) === false )
				html += "测试 失败，当前URL: " + n + "<br />";
			else
				html += "测试 成功，当前URL: " + n + "<br />";
		});
		$("#autoTestResult").html(html);
	});
	
</script>


</body>
</html>
